import React, { Component , PureComponent} from 'react'
import UserInfo from './UserInfo'
import {userAction} from '../../actions';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import { userService } from '../../service'
import  MakeUser  from './MakeUser'

class UserList extends PureComponent {

    constructor (props) {
        super(props)
        this.toAdd = this.toAdd.bind(this);
    }

    componentDidMount() {
        console.log(this.props);
        console.log("--------------UserList加载完成-------------------");
    }

    render() {
        console.log("--------------UserList渲染-------------------");
        const {userList} = this.props.userData;
        const users = userList.map((user)=>{
            return (<UserInfo actions = {this.props.actions} user = {user} />);
        });

        console.log(MakeUser)
        return (
            <div>
                <button onClick={this.toAdd}>添加</button>
                <table>
                    {users}
                </table>
                    <MakeUser userData = {this.props.userData}/>
            </div>
        )
    }

    toAdd(){
        console.log(this);
        
    }

}

export default UserList;